      1  /**

      2     A class that describes the effects of an earthquake.

      3  */

      4  public class Earthquake

      5  {

      6     private double richter;

      7

      8     /**

      9        Constructs an Earthquake object.

     10        @param magnitude the magnitude on the Richter scale

     11     */

     12     public Earthquake(double magnitude)

     13     {

     14        richter = magnitude;

     15     }

     16

     17     /**

     18        Gets a description of the effect of the earthquake.

     19        @return the description of the effect

     20     */

     21     public String getDescription()

     22     {

     23        String description;

     24        if (richter >= 8.0)

     25        {

     26           description = "Most structures fall";

     27        }

     28        else if (richter >= 7.0)

     29        {

     30           description = "Many buildings destroyed";

     31        }

     32        else if (richter >= 6.0)

     33        {

     34           description = "Many buildings considerably damaged, some collapse";

     35        }

     36        else if (richter >= 4.5)

     37        {

     38           description = "Damage to poorly constructed buildings";

     39        }

     40        else

     41        {

     42           description = "No destruction of buildings";

     43        }

     44        return description;

     45     }

     46  }